//index.js
//获取应用实例
const app = getApp()
const fetch = require('../../utils/fetch.js')

Component({
  data: {
    checkAll: false
  },
  ready () {
    console.log(this.router);
  },
  router: {
    fn () {
      console.log(2)
    },
    name: 'category',
    parent: 'index',
    index: 10
  },
  methods: {
    add () {
      this.setData({
        categoryid: -1,
        showGoods: true
      })
      // todo 前端生成
    },
    remove (e) {
      console.log('删除')
    },
    enable (e) {
      console.log('启用')
    },
    disable (e) {
      console.log('禁用')
    },
    checkAll () {
      this.setData({
        checkAll: !this.data.checkAll
      })
    },
    editItem (e) {
      console.log(e.currentTarget.dataset.categoryid)
      this.setData({
        categoryid: e.currentTarget.dataset.categoryid,
        showGoods: true
      })
    },
    showdetail(e){
      console.log(e)
      this.setData({
        goodsid: e.detail,
        showDetail: true
      })
    },
    up () {
      console.log('排序往上')
    },
    down () {
      console.log('排序往下')
    },
    backcommoduty(){
      this.setData({
        categoryid: null,
        showGoods: false
      })
    },
    backgoods(){
      this.setData({
        goodsid: null,
        showDetail: false
      })
    }
  }
})
